package cn.tedu.micro.demo.websocket.controller;

import cn.tedu.micro.demo.websocket.points.MyFirstServerPoint;
import cn.tedu.micro.demo.websocket.points.MySecondServerPoint;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@Slf4j
public class TalkController {
    @Autowired
    private MyFirstServerPoint serverPoint;
    @Autowired
    private MySecondServerPoint secondServerPoint;
    @GetMapping("/send/msg")
    public String sendMsg(Integer userId,String msg){
        //希望业务 通过websocket终端,将msg推送给userId连接的客户端
        serverPoint.sendMsg2User(userId,msg);
        return "ok";
    }
    @GetMapping("/send/check")
    public String sendCheck(Integer userId,String msg){
        //希望业务 通过websocket终端,将msg推送给userId连接的websocket终端
        boolean result = secondServerPoint.sendMsg2User(userId,msg);
        return result?"ok":"fail";
    }
}
